﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using ExFlash.Editors;

namespace ExFlash.Records
{
    [Editor(typeof(RGBRecordEditor), typeof(UITypeEditor))]
    public class RGBRecord : ISwfSerializable
    {
        public const int RGBRecordSize = 3;
        
        public Byte Red
        {
            get;
            protected set;
        }

        public Byte Green
        {
            get;
            protected set;
        }

        public Byte Blue
        {
            get;
            protected set;
        }

        static public explicit operator RGBRecord(Color color)
        {
            return new RGBRecord {Red = color.R, Green = color.G, Blue = color.B};
        }

        public virtual Color GetColor()
        {
            return Color.FromArgb(Red, Green, Blue);
        }
        
        #region ISwfSerializable Members

        virtual public void SwfDeserialize(BinaryBitReader reader)
        {
            Red = reader.ReadByte();
            Green = reader.ReadByte();
            Blue = reader.ReadByte();
        }

        virtual public void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
